def is_correct_brackets(text):
    while '()' in text or '[]' in text or '{}' in text or '<>'in text:
        text = text.replace('()','')
        text = text.replace('[]','')
        text = text.replace('{}','')
        text = text.replace('<>','')

  # Возвращаем True, если text c пустой строкой
    return not text 


s = 'Y'

while s != 'n':
    inputString = input('Введите последовательность скобок: ')
    print(is_correct_brackets(inputString.strip()))
    print('Continue?', 'Enter n or y')
    s = input()
print('end')                   
          
